package com.job.meeting.pojo;

import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Table;

@Data//注解在类上；提供类所有属性的 getting 和 setting 方法，此外还提供了equals、canEqual、hashCode、toString 方法
@AllArgsConstructor//有参构造器
@NoArgsConstructor//无参构造器
@Table(name = "booking")//声明此对象映射到数据库的数据表，通过它可以为实体指定表(table)
public class bookingTemp implements Comparable<bookingTemp>{
    private int id;
    private int meeting_room_id;
    private int user_id;
    private String purpose;
    private int participants;
    private bookingTime time_occupied;
    private String contact;
    private int status;//状态state，丈育写错了
    private String comment;
    private String reply;
    private String real_name;

    //构造函数，输入json字段以创造对应的对象
    public bookingTemp(booking b){
        this.setId(b.getId());
        this.setMeeting_room_id(b.getMeeting_room_id());
        this.setUser_id(b.getUser_id());
        this.setPurpose(b.getPurpose());
        this.setParticipants(b.getParticipants());
        this.setTime_occupied(new Gson().fromJson(b.getTime_occupied(), bookingTime.class));
        this.setContact(b.getContact());
        this.setStatus(b.getStatus());
        this.setComment(b.getComment());
        this.setReply(b.getReply());
        this.setReal_name(b.getReal_name());
    }

    //覆写toString函数，返回一个对象对应的json字段
    public String toString(){
        return new Gson().toJson(this);
    }

    @Override
    public int compareTo(bookingTemp o) {
        return this.time_occupied.compareTo(o.getTime_occupied());
    }

/*
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getMeeting_room_id() {
        return meeting_room_id;
    }

    public void setMeeting_room_id(int meeting_room_id) {
        this.meeting_room_id = meeting_room_id;
    }

    public int getUser_id() {
        return user_id;
    }

    public void setUser_id(int user_id) {
        this.user_id = user_id;
    }

    public String getPurpose() {
        return purpose;
    }

    public void setPurpose(String purpose) {
        this.purpose = purpose;
    }

    public int getParticipants() {
        return participants;
    }

    public void setParticipants(int participants) {
        this.participants = participants;
    }

    public String getTime_occupied() {
        return time_occupied;
    }

    public void setTime_occupied(String time_occupied) {
        this.time_occupied = time_occupied;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getReply() {
        return reply;
    }

    public void setReply(String reply) {
        this.reply = reply;
    }

 */

}

